package com.jic.manager.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.manager.mapper.CmsModuleChannelMapper;
import com.jic.manager.entity.CmsModuleChannel;
import com.jic.manager.service.CmsModuleChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * cms模块渠道关系表
 * @author : 
 * @email : 
 * @since : 2020-03-05 12:00:05
 * @version : v1.0.0
 */
@Service
public class CmsModuleChannelServiceImpl implements CmsModuleChannelService {

    @Autowired
    private CmsModuleChannelMapper cmsModuleChannelMapper;

    @Override
    public long insert(CmsModuleChannel cmsModuleChannel) {
        long flag = cmsModuleChannelMapper.insert(cmsModuleChannel);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return cmsModuleChannelMapper.delete(id);
    }

    @Override
    public long update(CmsModuleChannel cmsModuleChannel) {
        return cmsModuleChannelMapper.update(cmsModuleChannel);
    }

    @Override
    public CmsModuleChannel queryByPrimaryKey(Long id){
        return cmsModuleChannelMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<CmsModuleChannel> query(CmsModuleChannel cmsModuleChannel){
        return cmsModuleChannelMapper.query(cmsModuleChannel);
    }

    @Override
    public PageResult<CmsModuleChannel> queryPage(CmsModuleChannel cmsModuleChannel, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<CmsModuleChannel> list = cmsModuleChannelMapper.queryPage(startIndex, pageQuery.getLimit(), cmsModuleChannel);
        long count = cmsModuleChannelMapper.queryPageCount(cmsModuleChannel);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}